<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/9/12
 * Time: 1:00 PM
 * To change this template use File | Settings | File Templates.
 */
jimport('joomla.application.component.controllerform');

class VastControllerDonvitheokhois extends JControllerForm
{
    /**
     * Class constructor.
     *
     * @param   array  $config  A named array of configuration variables.
     *
     * @since	1.6
     */
    function __construct($config = array())
    {

        parent::__construct($config);
    }

    public function show2donvi($key = null, $urlVar = null)
    {
        // Initialise variables.
        $app = JFactory::getApplication();
        $model = $this->getModel();
        $cid = JRequest::getVar('cid', array(), 'post', 'array');

        // Determine the name of the primary key for the data.
        if (empty($key))
        {
            $key = 'khoi_id';
        }

        // To avoid data collisions the urlVar may be different from the primary key.
        if (empty($urlVar))
        {
            $urlVar = $key;
        }
        // Get the previous record id (if any) and the current record id.
        $recordId = (int) (count($cid) ? $cid[0] : JRequest::getInt($urlVar));
        
        $session = JFactory::getSession();
        $session->set('donvitheokhois.khoi_id', $recordId);
        
        $this->setRedirect(
            JRoute::_(
                'index.php?option=' . $this->option . '&view=donvitheokhois' . $this->getRedirectToItemAppend($recordId, $urlVar), false
            )
        );
    }
}